package com.zisuyi.uilibrary.module.activty.redeem


import android.view.View
import android.widget.TextView
import androidx.annotation.StringRes
import androidx.annotation.StyleRes
import androidx.viewbinding.ViewBinding
import com.weilele.mvvm.utils.activity.setTextResColor
import com.weilele.mvvm.utils.activity.setTextStringColor
import com.weilele.mvvm.utils.activity.textFrom
import com.weilele.mvvm.utils.vLaout.VLayoutHolder
import com.zisuyi.uilibrary.R


class ButtonHolder: VLayoutHolder<Pair<@StringRes Int, @StyleRes Int>, ViewBinding> {

    constructor(binding: ViewBinding) : super(binding)
    constructor(itemView: View) : super(itemView)

    override fun bindData(data: Pair<Int, Int>) {
        (itemView as TextView).let {
            it.textFrom(data.first)
            when (data.second) {
                R.style.AppGrnButton -> {
                    it.setBackgroundResource(R.drawable.btn_bg_grn)
                    it.setTextResColor(R.color.colorText)
                }
                R.style.AppYellowButton -> {
                    it.setBackgroundResource(R.drawable.btn_bg_yellow)
                    it.setTextStringColor("#80000000")
                }
            }
        }
    }
}